home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
byte0387.arc
/
LISPTEST.DOC
< prev
next >
Wrap
Lisp/Scheme
|
1980-01-01
|
9KB
|
441 lines
;; BYTE TI Scheme Benchmark Source 5-20-86 WGW
;; Time Test
(define (time-function function)
(gc) ;; make sure system is consistent
(let ((start-time (runtime)))
(function)
(/ (- (runtime) start-time) 100.0)
)
)
(define (time-test function)
(gc) ;; make sure system is consistent
(let ((start-time (runtime)))
(loop-test function 5000)
(/ (- (runtime) start-time) 100.0)
)
)
;; Loop test to get function time into timable range
(define (loop-test function limit)
(do ((i 1 (1+ i)))
((>=? i limit))
(function)
)
)
;; Dummy function to test LOOP-TEST
(define (dummy))
;; List construction test
(define cons-var nil)
(define (cons-test) (cons cons-var cons-var))
;; Integer addition test
(define add-a 1)
(define add-b 2)
(define (add-test) (+ add-a add-b))
;; Integer multiplication test
(define mult-a 1)
(define mult-b 2)
(define (mult-test) (* mult-a mult-b))
;; Floating point addition test
(define fadd-a 1.2)
(define fadd-b 234324.3)
(define (fadd-test) (+ fadd-a fadd-b))
;; Floating point multiplication test
(define fmult-a 1.2)
(define fmult-b 234324.3)
(define (fmult-test) (* fmult-a fmult-b))
;; Assignment Test (Load from variable and set global variable)
(define assign-a '(1 2 3))
(define (assign-test) (set! assign-a assign-a))
;; Local Assignment Test
(define (local-assign) (let ((x '())) (set! x '(1 2 3))))
;; List Indexing Test
(define (build-list length)
(if (zero? length)
'()
(cons length (build-list (sub1 length)))
)
)
(define list-a)
(set! list-a (build-list 128))
(define (list-index) (list-ref list-a 120))
;; Vector Index Test
(define vect-a)
(set! vect-a (make-vector 128 1))
(define (vector-index) (vector-ref vect-a 120))
;; String Index Test
(define string-a)
(set! string-a (make-string 128 #\X ))
(define (string-index) (string-ref string-a 120))
;; The good old Prime Number Sieve Test (Test on only 1 iteration)
(define (sieve)
(letrec ((count 0) ;; number of primes found
(size 7000) ;; size of sieve array
(flags (make-vector (add1 size) 0))
)
(do ((i 0 (add1 i))) ;; scan array from start
((> i size) count) ;; to finish and return primes found
(if (zero? (vector-ref flags i))
(let ((prime (+ i i 3)))
(do ((k (+ i prime) (+ k prime)))
((> k size) (set! count (add1 count)))
(vector-set! flags k 1)
) ;; reset non-prime flags
)
)
)
)
)
;; BYTE Calculation Test (Time only 1 iteration, looping is done internally)
(define (calc)
(do ((a 2.71828) ;; setup parameters
(b 3.14159)
(c 1.0)
(i 1 (add1 i))
)
((=? i 5000) (- c 1)) ;; exit when end of test with error
(set! c (* c a)) ;; perform calculations
(set! c (* c b))
(set! c (/ c a))
(set! c (/ c b))
)
)
;; End of BYTE TI Scheme Benchmark Source
"BYSO Lisp Benchmark 1-4-86 WGW"
"Test Loop"
(defun loop-test (fn limit)
(do (( i 1 ( + i 1 )))
((= i limit))
(fn) ) )
(defun dummy ())
"CONS Test"
(setq cons-a nil)
(defun cons-test () (cons cons-a cons-a))
"Integer Addition Test"
(setq add-a 1 add-b 2)
(defun add-test () (+ add-a add-b))
"Integer Multiplication Test"
(setq multiply-a 1 multiply-b 2)
(defun multiply-test () (* multiply-a multiply-b))
"Assignment Test"
(setq assign-a '(1 2 3))
(defun assign-test () (setq assign-a assign-a))
"List Indexing Test"
(setq list-index-list '())
(do ((i 1 (+ i 1)))
((= i 128))
(setq list-index-list (cons i list-index-list)) )
(defun list-index () (nth 120 list-index-list))
"Vector Index Test"
(setq vector-test-array (array 'sexpr 128))
(defun vector-index () (aref vector-test-array 120))
"String Index Test"
(setq string-test-array (array 'char 128))
(defun string-index () (aref string-test-array 120))
"Write test creates a new file and writes 64 kbytes to it."
( defun write-test ()
( do-write-test ( open 'b:test )
512
( array 'char 128 )
)
)
( defun do-write-test ( file records buffer )
( do ()
(( zerop ( setq records ( - records 1 ))) ( close file ))
( princ buffer file )
)
)
; Waltz Lisp Benchmark 1-4-86 WGW
;
; Test Loop
(def loop-test (lambda (fn limit)
(do ((i 1 ( + i 1 )))
((equal i limit))
(fn) ) ))
(def dummy (lambda ()))
; CONS Test
(setq cons-a nil)
(def cons-test (lambda () (cons cons-a cons-a)))
; Integer Addition Test
(setq add-a 1)
(setq add-b 2)
(def add-test (lambda () (+ add-a add-b)))
; Integer Multiplication Test
(setq multiply-a 1)
(setq multiply-b 2)
(def multiply-test (lambda () (* multiply-a multiply-b)))
; Assignment Test
(setq assign-a '(1 2 3))
(def assign-test (lambda () (setq assign-a assign-a)))
; List Indexing Test
(setq list-index-list '())
(do ((i 0 (+ i 1)))
((equal i 128))
(setq list-index-list (cons i list-index-list)) )
(def list-index (lambda () (nth 120 list-index-list)))
; Vector Index Test (Arrays Not Supported)
; String Index Test
(setq string-test-array "" )
(do ((i 0 (+ i 1)))
((equal i 128))
(setq string-test-array (cat "1" string-test-array)) )
(def string-index (lambda () (substring string-test-array 120 120)))
; Write test creates a new file and writes 64 kbytes to it.
(def write-test (lambda ()
( do-write-test ( outfile "b:test" )
512
string-test-array ) ))
(def do-write-test (lambda (file records buffer)
( do ()
(( zerop ( setq records ( - records 1 ))) ( close file ))
( princ buffer file ) ) ))
;; Golden Common Lisp Benchmark 1-4-86 WGW
;; Test Loop
(defun loop-test (fn limit)
(do (( i 1 ( + i 1 )))
((= i limit))
(apply fn nil) ) )
(defun dummy () )
;; CONS Test
(setq cons-a nil)
(defun cons-test () (cons cons-a cons-a))
;; Integer Addition Test
(setq add-a 1 add-b 2)
(defun add-test () (+ add-a add-b))
;; Integer Multiplication Test
(setq multiply-a 1 multiply-b 2)
(defun multiply-test () (* multiply-a multiply-b))
;; Floating Point Addition Test
(setq fp-add-a 1.2 fp-add-b 234324.3)
(defun fp-add-test () (+ fp-add-a fp-add-b))
;; Floating Point Multiplication Test
(setq fp-multiply-a 1.2 fp-multiply-b 234324.3)
(defun fp-multiply-test () (* fp-multiply-a fp-multiply-b))
;; Assignment Test
(setq assign-a '(1 2 3))
(defun assign-test () (setq assign-a assign-a))
;; List Indexing Test
(setq list-index-list '())
(do ((i 1 (+ i 1)))
((= i 128))
(setq list-index-list (cons i list-index-list)) )
(defun list-index () (nth 120 list-index-list))
;; Vector Index Test
(setq vector-test-array (make-array 128 :initial-element nil))
(defun vector-index () (aref vector-test-array 120))
;; String Index Test
(setq string-test-array
(make-array 128 :element-type 'string-char :initial-element 32))
(defun string-index () (aref string-test-array 120))
"Write test creates a new file and writes 64 kbytes to it."
(defun write-test ()
(do-write-test (open "b:test" :direction ':output)
512
(make-array 128 :element-type 'string-char)
)
)
( defun do-write-test ( file records buffer )
( do ()
(( zerop ( setq records ( - records 1 ))) ( close file ))
( princ buffer file )
)
)